<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>/ht/">
<meta charset="UTF-8">
<title>Add ElementType</title>
<link rel="stylesheet" href="css/xiaoge.css">
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/xiaogemsg.js"></script>
<script type="text/javascript">
	$(function(){
		//验证用户是否为空
		$("#managerName").bind("blur",function(){
			var managerName = $("#managerName").val().trim();
			if(managerName==null || managerName==""){
				xiaogemsg(200,"请输入用户名！",2000);
				$("#managerName").css("border-color","red");
			}else{
				$("#managerName").css("border-color","gray");
			}
		});
		//验证密码是否为空
		$("#managerPassword").bind("blur",function(){
			var managerPassword = $("#managerPassword").val().trim();
			if(managerPassword==null || managerPassword==""){
				xiaogemsg(200,"密码不能为空，请输入密码！",2000);
				$("#managerPassword").css("border-color","red");
			}else{
				if(managerPassword.length<6){
					xiaogemsg(200,"密码的长度不能小于六位",2000);
					$("#managerPassword").css("border-color","red");
				}else{
					$("#managerPassword").css("border-color","gray");
				}
				
			}
		});
		//验证用户是否为空
		$("#managerStatic").bind("blur",function(){
			var managerStatic = $("#managerStatic").val().trim();
			if(managerStatic==null || managerStatic==""){
				xiaogemsg(200,"状态只不能为空！",2000);
				$("#managerStatic").css("border-color","red");
			}else{
				if(managerStatic!=0 && managerStatic!=1){
					xiaogemsg(200,"状态只能是0或1！",2000);
					$("#managerStatic").css("border-color","red");
				}else{
					$("#managerStatic").css("border-color","gray");
				}
			}
		});
		//验证重复密码是否为空
		$("#oldPassword").bind("blur",function(){
			var oldPassword = $("#oldPassword").val().trim();
			var managerPassword = $("#managerPassword").val().trim();
			if(oldPassword==null || oldPassword==""){
				xiaogemsg(200,"密码不能为空，请输入密码！",2000);
				$("#oldPassword").css("border-color","red");
			}else{
				if(oldPassword.length<6){
					xiaogemsg(200,"密码的长度不能小于六位",2000);
					$("#oldPassword").css("border-color","red");
				}else{
					if(oldPassword!=managerPassword){
						xiaogemsg(200,"你两次输入的密码不相同",2000);
						$("#oldPassword").css("border-color","red");
						$("#managerPassword").css("border-color","red");
					}else{
						$("#managerPassword").css("border-color","gray");
						$("#oldPassword").css("border-color","gray");
					}
				}
			}
		});
		/* 保存 */
		$("#keep").click(function(){
			var managerStatic = $("#managerStatic").val().trim();
			if(managerStatic==null || managerStatic==""){
				$("#managerStatic").css("border-color","red");
				alert("用户名不能为空");
				return false;
			}
			var oldPassword = $("#oldPassword").val().trim();
			var managerPassword = $("#managerPassword").val().trim();
			if(oldPassword==null || oldPassword==""){
				xiaogemsg(200,"密码不能为空，请输入密码！",2000);
				$("#oldPassword").css("border-color","red");
				return false;
			}else{
				if(oldPassword.length<6){
					xiaogemsg(200,"密码的长度不能小于六位",2000);
					$("#oldPassword").css("border-color","red");
					return false;
				}else{
					if(oldPassword!=managerPassword){
						xiaogemsg(200,"你两次输入的密码不相同",2000);
						$("#oldPassword").css("border-color","red");
						$("#managerPassword").css("border-color","red");
						return false;
					}else{
						$("#managerPassword").css("border-color","gray");
						$("#oldPassword").css("border-color","gray");
					}
				}
				
			}
			var frm = $("#frm").serialize();
			$.post("../managerInfoAction!updateManagerInfo.action",frm,function(data){
				
				if(data){
					xiaogemsg(200,"修改成功!",2000);
					parent.window.history.go(0);
				}else{
					xiaogemsg(200,"修改失败!",2000);
				}
			});
		});
		
		//关闭窗口
		$("#cancel").click(function(){
			closeThis();
		});
		
	});
	//关闭当前窗口的方法
	function closeThis(){
		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
		return;
	}
</script>
</head>
<body>
	<form id="frm" action="" method="post">
		<input type="hidden" id="op" name="op" value="AddElemenContent">
		<div class="xiaoge-div-input">
			<div class="xiaoge-div-input-div">
				<label class="xiaoge-div-input-lable"> I&nbsp;&nbsp;&nbsp;&nbsp;D&nbsp;&nbsp;:</label>
			</div>
			<input type="text" class="input" id="managerId" name="manager.managerId" readonly="readonly" value="${manager.managerId }"/>
		</div>
		<div class="xiaoge-div-input">
			<div class="xiaoge-div-input-div">
				<label class="xiaoge-div-input-lable">用&nbsp;户&nbsp;名:</label>
			</div>
			<input type="text" class="input" id="managerName" name="manager.managerName" value="${manager.managerName }" placeholder="*请输入用户名"/>
		</div>
		<div class="xiaoge-div-input">
			<div class="xiaoge-div-input-div">
				<label class="xiaoge-div-input-lable">密&nbsp;&nbsp;&nbsp;&nbsp;码&nbsp;&nbsp;:</label>
			</div>
			<input type="text" class="input" id="managerPassword" name="manager.managerPassword" value="${manager.managerPassword }" placeholder="*请输入密码"/>
		</div>
		<div class="xiaoge-div-input">
			<div class="xiaoge-div-input-div">
				<label class="xiaoge-div-input-lable">确认密码:</label>
			</div>
			<input type="text" class="input" id="oldPassword" value="${manager.managerPassword }" placeholder="*请输入重复密码"/>
		</div>
		<div class="xiaoge-div-input">
			<div class="xiaoge-div-input-div">
				<label class="xiaoge-div-input-lable">状&nbsp;&nbsp;&nbsp;&nbsp;态&nbsp;&nbsp;:</label>
			</div>
			<input type="text" class="input" id="managerStatic" name="manager.managerStatic" placeholder="*请输入重复密码" value="${manager.managerStatic }"/>
		</div>
		<div id="content" style="height: 220px;"></div>
		<div class="xiaoge-div-input">
			<div style="margin-right: 20px;float:right;">
				<input type="button" class="xiaoge-btn" id="keep" value=" 保 存 ">
				<input type="button" class="xiaoge-btn" id="cancel" style="margin-left:10px;background-color:#FF5722;" value=" 取 消 ">
			</div>
		</div>
	</form>
</body>
</html>